# v412 Workspace Type / Subscription Schema Rule

Before registration, billing gates, plan visibility, portal access, broker distribution, or internal load-board access are enforced, Prisma must explicitly represent the required source-of-truth fields. Inferred workspace type is review-only and must not be used as a hard entitlement gate. Drivers remain owned interfaces under the workspace they drive for unless a later approved product decision creates a paid driver product. Broker load distribution and internal load-board activity must be entitlement-gated, usage-tracked, approval/audit-backed, and Super Admin-visible before live expansion.

# v411 Workspace Type Control Rule

Until Prisma is explicitly updated, workspace type and account class must be treated as inferred planning data only. Super Admin may review these values, but product logic must not pretend they are durable stored truth. Future registration, billing, portal, and entitlement enforcement work must add explicit schema support before relying on workspace type as a hard gate.

# Dispatch Spot Build Rules

This file must be reviewed before every build cycle.

## 1. Core Product Rule

Dispatch Spot must reduce dispatching complexity, not add to it.

The app can use advanced technology behind the scenes, but normal users should only see clear work, clear choices, and clear next actions.

## 2. User Surface Rule

Normal user-facing pages must not become setup, testing, debug, readiness, or configuration pages.

If a user does not need something to complete the task on that page, it should not be visible there.

## 3. Settings Placement Rule

Provider setup, credentials, API keys, OAuth, SMTP, IMAP, Twilio, Stripe, QuickBooks, Google Maps, and other third-party integrations belong in:

`/company/integrations`

They do not belong on daily work pages such as CORI Mail, CORI Briefing, Dispatch Board, Loads, Trucks, Billing, Routes, or Documents.

## 4. CORI Surface Rule

CORI pages are AI work surfaces.

CORI pages may show:

- briefings
- plain explanations
- suggested actions
- editable drafts
- approval controls
- next steps

CORI pages should not show:

- raw credentials
- API setup forms
- provider configuration forms
- development/testing language
- technical readiness panels
- debug details

## 5. Super Admin Rule

Platform monitoring, support review, tenant-level checks, deep readiness, internal operations, and platform controls belong in Super Admin.

Super Admin should not replace Workspace Admin settings. Workspace-specific setup belongs in Workspace Settings.

## 6. Language Rule

Use simple, clear language for normal users.

Prefer:

- Connect email
- Review before sending
- Needs attention
- Open balance
- Truck is losing money
- Open Email Settings

Avoid on normal user pages:

- provider transport
- execution pipeline
- schema-backed
- persistence state
- token readiness
- runtime validation
- encrypted payload

Technical language may be used only in developer documentation, Super Admin, or clearly admin-only settings where the user needs the technical detail.

## 7. Build Cycle Rule

Each build must follow this order:

1. Review this rules file.
2. Review the current baseline version.
3. Confirm the page/location where the feature belongs.
4. Build the smallest safe version.
5. Update controlled documentation inside `Project Documentation/`.
6. Report What changed.
7. Report What’s Visible by role/location.
8. Report Rule Check.
9. Provide the correct WHM command.
10. Provide the next check-in prompt.

## 8. Drift Prevention Rule

If a requested change conflicts with these rules, pause and explain the conflict before building.

If an earlier build violates these rules, correct the placement before adding more features.

## 9. Build Response Rule Check

Every completed build response must include this section:

```text
Rule Check

- User surface stayed clean: Yes/No
- Settings/configuration stayed in Workspace Settings: Yes/No
- CORI page stayed AI/action-focused: Yes/No
- Technical/provider details hidden from normal users: Yes/No
- Simple language used: Yes/No
- Prisma schema changed: Yes/No
```

If any answer is No, the build is not complete and the next package should be a correction package.

## 10. Current Enforcement Note

As of v369, CORI Mail must not contain SMTP credential entry, OAuth setup forms, API keys, or provider testing panels. Those belong in Workspace Settings > Third-Party Integrations > Email.

## 11. Page Usefulness Rule

Before adding, expanding, or keeping a page, confirm the page helps the user complete one clear job.

Classify every page as one of these:

- daily work surface
- CORI assistant surface
- Workspace Settings surface
- Super Admin surface
- hidden/internal support surface

If a page is confusing, duplicated, not ready, or mainly exposes setup/debug/provider detail, do not expand it. Hide it, merge it, rebuild it, or move it to the correct settings/admin area.

Normal users should not need to understand platform internals to dispatch trucks.

## 12. Retired Page Rule

Pages that fail the Page Usefulness Rule should be removed from normal navigation before more features are added.

As of v371, these normal user pages are retired from the sidebar and redirected:

- `/load-board` redirects to `/loads` because the future public spot-market load board will be built separately on the main domain.
- `/intelligence` redirects to `/crm` because research and lead follow-up belong inside CRM or CORI later, not as a confusing standalone page.
- `/reports` redirects to `/dashboard` because reporting should be rebuilt as plain CORI briefings and simple page-level insights, not as a separate analytics maze.
- `/reports/dispatch` redirects to `/dispatch`.
- `/reports/loads` redirects to `/loads`.
- `/reports/finance` redirects to `/cori/financial`.
- `/reports/crm` redirects to `/crm`.
- `/workspaces` redirects to `/company` for workspace users and `/admin/workspaces` for Super Admin users.

Do not reintroduce these as normal sidebar pages unless they are rebuilt around one clear user job and approved in a build check-in.

## 13. Workspace Settings vs Integrations Rule

As of v372, `/company` is only for company profile, team access, and simple setup links.

All provider setup belongs in `/company/integrations`, including:

- Email
- Custom SMTP
- Google Maps API
- Twilio
- QuickBooks API
- Stripe Connect
- future API connections

Do not place provider credentials, API keys, OAuth setup, webhook setup, SMTP fields, Twilio setup, or integration readiness details on `/company`, CORI pages, billing pages, dispatch pages, load pages, or documents pages.

## 14. Work Surface Separation Rule

As of v373, these daily work surfaces have separate jobs:

- Dispatch Board is for live dispatch execution.
- Loads is for load records, filters, details, and corrections.
- Billing Records is for invoices, unpaid loads, and payment follow-up.
- CORI Financial is for the plain AI money briefing, not invoice record work.
- Paperwork is for missing proof, PODs, BOLs, rate confirmations, and file linking.
- CRM is for companies, brokers, and shippers. Drivers and owner operators stay under People & Assets.

Do not merge these pages just because they share data. Keep the page only if the user can understand its one clear job.

## 15. List Page Cleanup Rule

As of v374, high-use list pages must stay focused on the record type the user opened.

- Loads should stay focused on finding and opening load records. Extra reporting should not appear on the main page.
- Routes should start with load, truck, and driver. Internal readiness or data-contract checks should not be visible to normal users.
- Drivers and Owner Operators belong under People & Assets, not CRM. Do not show CRM workspace switching on those pages.
- Companies, Brokers, and Shippers belong under CRM & Partners. Keep those list pages focused on relationship records and follow-up.
- Do not add analytics cards, retired report links, or technical continuity panels to these list pages unless they are hidden from normal users or rebuilt in plain language around one clear job.

## 16. Detail Page Cleanup Rule

As of v375, detail pages must open with the record facts and the next useful action, not with internal handoff, readiness, lifecycle, or history blocks.

For normal users:

- Keep the main record, contact, route, money, truck, driver, and notes visible.
- Keep the main action buttons visible.
- Collapse deeper setup checks, ownership controls, call-history support, CRM history, and readiness panels behind simple "Show" sections.
- Use simple labels such as Paperwork check, Follow-up controls, Activity history, and Setup checks.
- Avoid making detail pages feel like internal operating manuals.

The user should be able to open a record and quickly answer: what is this, who is involved, what matters now, and what should I do next?

## 17. Form, Invoice, and Subpage Cleanup Rule

As of v376, create/edit forms, invoice pages, truck subpages, profile/security, Workspace Settings, and Third-Party Integrations must follow the same simple-surface standard.

- Forms should ask for the fields needed to save the record, not teach the whole operating system.
- Optional checks should be collapsed behind simple labels such as Show helpful checks.
- Invoice pages should show the invoice first. Billing and paperwork checks may exist, but they should not crowd the invoice view.
- Truck subpages should use plain job names: Current Load, Next Load, Money, Paperwork, and History.
- Profile & Security should focus on name, email, password, verification, and clear session safety. Deep policy details should stay collapsed.
- Workspace Settings should stay focused on company profile and team access.
- Third-Party Integrations may hold setup details, but the wording should still be as plain as possible.

If a form, invoice, or subpage starts showing internal readiness, provider, lifecycle, or continuity language by default, move that content behind a collapsed section or to the correct settings/admin area.


## 18. High-Use Work Surface Cleanup Rule

As of v377, CORI Briefing, Dispatch Board, Paperwork, Billing Records, and CORI pages must keep the user's immediate job first.

For normal users:

- CORI Briefing should summarize today's work and link to the right work surface. It should not show roadmap language or future feature planning.
- Dispatch Board should stay focused on live load movement. Deeper reminders and board numbers should remain optional or hidden unless directly needed.
- Paperwork should use plain language: missing proof, files to link, rate confirmation, BOL, POD, and fast fixes.
- Billing Records should use plain money language: invoice, unpaid load, payment follow-up, paid load, and unpaid amount.
- CORI pages should behave like assistant work surfaces, not settings, provider, readiness, or development-review pages.
- Development notes, simplification reviews, roadmap notes, provider internals, and technical readiness language must not appear on normal user pages.

If a high-use page starts explaining how Dispatch Spot is built instead of helping the user finish the job, move that content to root documentation, Workspace Settings, Super Admin, or remove it from the user surface.

## 19. Hidden Section and Assistant Language Rule

As of v378, hidden or collapsed sections must still follow the same simple-language standard as the first visible page view.

Collapsed sections may contain extra help, but they should not expose internal build terms such as continuity, handoff, foundation, fallback, runtime, pipeline, dataset, provider transport, or activation state to normal users.

Use plain labels instead:

- Extra board actions
- Saved call notes
- Route checks
- Manual check
- Map check ready
- Weather check ready
- Stop check ready
- Driver briefing
- Next step
- Go back

CORI's Quotes and Routes are high-use assistant surfaces. They should explain what the user can do next, not how the voice or routing system is built.

## 20. Admin Placement and Truck Command Cleanup Rule

As of v379, Super Admin, Workspace Admin, and daily user surfaces must stay clearly separated.

- Super Admin is for platform support, workspace review, plan oversight, and account safety controls.
- Workspace Settings is for company profile, team access, and third-party setup links.
- Third-Party Integrations is for credentials, API keys, OAuth, provider tests, and connected accounts.
- Daily user pages must not tell users to work through Super Admin, inspect provider state, or understand internal setup language.
- Truck command pages should say truck, driver, current move, next load, paperwork, money, call help, and next step.
- CRM relationship pages should say lead follow-up, relationship follow-up, activity history, and possible duplicate check instead of Intelligence, handoff, lifecycle, or continuity language.

If a daily page needs an admin action, show a simple next step such as “Review the subscription plan” or “Open Workspace Settings,” not internal platform language.

## 21. Final User-Facing Language Sweep Rule

As of v380, every visible and collapsed user-facing section must be checked for internal system words before a build is packaged.

Normal users should not see words such as blocker, continuity, handoff, workflow, lifecycle, audit, execution, visibility, governance, activation, foundation, or provider state unless the page is clearly an admin/settings page and the word is necessary.

Use plain replacements instead:

- blocker -> issue or needs attention
- continuity / handoff -> return path, next step, or go back
- workflow -> work path or steps
- lifecycle -> paperwork stages or record stages
- audit -> check or review
- execution -> movement or work
- visibility -> view, shown, or listed
- provider setup -> email setup, phone setup, map setup, or connected account

Collapsed helper panels are not exempt. If a user opens a hidden section, it must still read like help, not like engineering notes.

## 22. Build Preflight Guard Rule

As of v381, every build package should include and run the Dispatch Spot preflight guard before TypeScript and Next build.

Run:

```bash
npm run dispatchspot:preflight
```

The preflight checks local source imports for missing files before `tsc` and `next build`. This is meant to catch cleanup bridge mistakes such as renamed paperwork, billing, dispatch, or CORI helper components before the server build reaches Webpack.

The preflight may also print language warnings for selected internal terms on normal user surfaces. These warnings do not fail the build; they are reminders to keep normal pages simple.

The preflight does not replace:

- TypeScript
- Next build
- Prisma generate/db push when the schema changes
- the Rule Check section in the handoff response

If the preflight fails, ship a `.1` correction package before adding new product features.

## 23. Simple App-Style Notifications Rule

As of v382, notifications should feel like a normal app or phone alert system.

Normal users may see:

- a top-bar notification bell
- a simple alert list
- clear alert types such as Dispatch, Paperwork, Billing, and Task
- direct links to the record that needs attention
- plain delivery wording such as In-app alerts, Email alerts, Text alerts, and Push alerts

Normal users should not see:

- notification governance queues
- sender-domain review language
- SMTP setup
- Twilio setup
- webhooks
- API keys
- technical delivery diagnostics
- provider readiness panels

Delivery-provider setup belongs in Workspace Settings and Third-Party Integrations. Super Admin may later get deeper monitoring, but the normal notification surface must stay simple.

## 24. Notification Preference Rule

As of v383, notifications must stay simple and app-style.

- The notification bell and `/notifications` page are for clear alerts only.
- Each user may choose in-app, email, and text alert preferences in Workspace Settings > Notifications, in simple language.
- Email, text, push, SMTP, Twilio, and provider setup must stay in Workspace Settings > Third-Party Integrations.
- Workspace Settings > Notifications may explain that email/text delivery is opt-in and not live until setup is connected. The normal `/notifications` page must stay alert/action-only and must not show API keys, SMTP fields, phone provider setup, debug status, delivery logs, preference controls, phone capture, or opt-in/out controls.
- Text alerts must stay urgent-only and opt-in.
- Alerts should link to the record that needs action instead of explaining system internals.

## 25. Notification Delivery Through Workspace Integrations Rule

As of v384, email and text notification delivery must use Workspace Settings > Third-Party Integrations.

Users may choose what alerts they want in Workspace Settings > Notifications. The `/notifications` page may show the alert list, read/unread state, hidden alerts, and direct alert actions only.

Normal users should not see:

- SMTP host fields
- app passwords
- Twilio auth tokens
- API keys
- webhook setup
- delivery debug logs

Workspace Admins connect company email under the Email tab and Twilio under the Twilio tab. Workspace Settings > Notifications may show "Ready," "Needs setup," or "Off," but the normal /notifications alert list must stay alert-only.

Email alert delivery may send only through a connected and tested Custom SMTP account. Text alerts remain urgent-only and opt-in; Twilio setup can be saved, but user phone opt-in must exist before real text sends are enabled.

## 26. Urgent Text Opt-In Rule

As of v385, text alerts must remain urgent-only and explicitly opt-in.

Users may enter their own mobile number and agree to receive urgent text alerts in Workspace Settings > Notifications, not on the user-facing `/notifications` alert list.

Normal users must not see:

- Twilio account SID
- Twilio auth token
- messaging service IDs
- webhook setup
- delivery debug logs
- SMS provider diagnostics

Those setup details belong in Workspace Settings > Third-Party Integrations.

A saved phone number alone is not enough. Urgent text alerts require clear opt-in language and an opt-in timestamp before any future text delivery can use that number.

Users must also be able to turn off urgent text alerts from the same Workspace Settings > Notifications area.

## 27. Guarded Urgent Text Delivery Prep Rule

As of v386, urgent text alerts may be prepared only after the user has entered a mobile number and clearly opted in.

Workspace Settings > Notifications may show:

- whether urgent text alerts are off, need setup, or are ready to prepare
- a simple preview of the urgent text message
- the user's destination phone number
- clear wording that the preview is not sent yet

The normal `/notifications` alert list must stay limited to alerts, read/unread, hide/show, and opening the work record that needs attention.

The normal Notifications page must not show:

- Twilio account SID
- Twilio auth token
- messaging service IDs
- webhook URLs
- provider delivery diagnostics
- technical send logs

Twilio setup stays in Workspace Settings > Third-Party Integrations. Actual text sending remains locked until the final approval, audit, and delivery guard is built.

## 28. Guarded SMS Send and Audit Rule

As of v387, urgent text alerts may send only after all of these are true:

- the user entered a mobile number,
- the user explicitly opted in to urgent text alerts,
- the workspace has Twilio setup saved in Workspace Settings > Third-Party Integrations,
- Dispatch Spot prepares a short text preview,
- the user approves the send from the preview,
- Dispatch Spot records the send attempt in an audit table.

Workspace Settings > Notifications may show:

- text readiness,
- destination phone number,
- message preview,
- a clear Send urgent text button,
- a simple success or failure result.

The normal `/notifications` alert list must not become a delivery settings or delivery testing page.

The normal Notifications page must not show:

- Twilio account SID,
- Twilio auth token,
- messaging service ID,
- webhook URL,
- raw provider diagnostics,
- raw delivery logs.

Provider setup remains in `/company/integrations`. Detailed provider support remains a settings/admin concern, not a normal alert-page concern.

## 29. Notification Read/Unread and Hide Rule

As of v388, notification read/unread and hide behavior is a personal user alert action.

The normal Notifications page may show:

- unread alert count,
- read/unread labels,
- Mark read,
- Mark unread,
- Mark all read,
- Hide,
- Show again,
- simple hidden-alert count.

The normal Notifications page must not show:

- provider delivery logs,
- SMTP setup,
- Twilio setup,
- API keys,
- webhook setup,
- raw delivery diagnostics,
- internal alert-state technical wording.

The bell badge should count unread active alerts when in-app alerts are enabled. Hidden alerts should stay out of the active list for that user until the user chooses to show them again.

## 30. CORI Mail Approved-Send Rule

As of v389, CORI Mail may send a real email only after all of these are true:

- the workspace has a connected company email account in Workspace Settings > Third-Party Integrations,
- live CORI Mail sending is enabled at the server level,
- CORI shows the exact message body to the user,
- the user clicks a final approval send button,
- Dispatch Spot records the send attempt in the CORI Mail send audit table.

The normal CORI Mail page may show:

- email connection status in plain language,
- final approval status,
- Save draft,
- Prepare mailbox draft,
- Review send,
- Approve and send now,
- simple success or failure messages.

The normal CORI Mail page must not show:

- SMTP host,
- SMTP port,
- SMTP username,
- app password,
- OAuth secrets,
- provider diagnostics,
- raw delivery logs,
- API keys.

Provider setup remains in `/company/integrations`. CORI Mail stays focused on reading, explaining, drafting, work cards, review, and final user approval.



## 31. Notification Settings Relocation and Operational Surface Lock Rule

As of v390, `/notifications` is an alert/action surface only.

The normal `/notifications` page may show:

- active alerts,
- unread/read state,
- Mark read,
- Mark unread,
- Mark all read,
- Hide,
- Hidden alerts,
- Show again,
- direct links to the record that needs work.

The normal `/notifications` page must not show:

- notification preference toggles,
- email alert preference settings,
- text alert preference settings,
- phone number capture,
- urgent text opt-in or opt-out controls,
- delivery channel configuration,
- provider setup,
- test-send controls,
- provider diagnostics.

Notification preferences, phone-number capture, urgent-text opt-in/out, and delivery-readiness controls belong in Workspace Settings > Notifications. Provider credentials and connected accounts remain in Workspace Settings > Third-Party Integrations.

No operational page may become a settings page. Settings, preferences, integrations, opt-ins, provider setup, and configuration belong in Workspace Settings unless a future build prompt explicitly approves a different location and the Rule Check calls out that exception.

## 32. Documentation Source-of-Truth Rule

As of v391, the root documentation set must be read through the active source-of-truth structure, not by treating every historical build note as current guidance.

Before each build, review these in order:

1. the current user prompt and baseline,
2. `Project Documentation/Active/DISPATCH_SPOT_BUILD_RULES.md`,
3. `Project Documentation/00_CURRENT_OPERATING_MANUAL.md`,
4. `Project Documentation/06_CONSOLIDATED_ACTIVE_PRODUCT_ARCHITECTURE_MANUAL_V394.md`,
5. `Project Documentation/Active/DISPATCH_SPOT_DOCUMENTATION_SOURCE_OF_TRUTH.md`,
6. `Project Documentation/Active/DISPATCH_SPOT_SUPERSEDED_GUIDANCE_REGISTER.md`,
7. `Project Documentation/01_PREVIOUS_CHAT_REQUIREMENTS_REGISTER.md`,
8. `Project Documentation/07_CONTROLLED_DOCUMENTATION_RELOCATION_MANIFEST_V395.md` when touching documentation placement, cleanup, or root file behavior,
9. `Project Documentation/Active/PROJECT_HANDOFF.md` latest entry,
10. the relevant active module standard or architecture document inside `Project Documentation/`.

Older v-numbered documents are historical unless the current source-of-truth document says they are still active.

If an old document conflicts with a newer placement rule, do not follow the old document. Mark the old guidance as superseded and update `Project Documentation/Active/DISPATCH_SPOT_SUPERSEDED_GUIDANCE_REGISTER.md`.

Future builds must not create new root standalone documentation. Create durable rule, architecture, major module, deployment, protocol, correction-audit, changelog, handoff, and module-standard documentation inside `Project Documentation/`. The root `README.md` is only a pointer.

## 33. Current Operating Manual Rule

As of v392, every build must also review the compact current operating manual:

`Project Documentation/00_CURRENT_OPERATING_MANUAL.md`

This manual consolidates the active build procedure, WHM command format, version/package naming, response format, Rule Check format, placement rules, documentation rules, and previous-chat requirement review rule.

Older scattered protocol notes are historical unless they match the current operating manual and this build-rules file.

## 34. Project Documentation Folder Rule

As of v395, durable project documentation lives inside the controlled folder:

`Project Documentation/`

Do not create new root-level standalone documents for ordinary implementation details or documentation updates. The project root should keep only pointer files required to help a future builder find the controlled documentation folder.

Historical documentation must not be deleted. It should be classified, marked when superseded, and preserved inside the correct `Project Documentation/` subfolder.

## 35. Previous Chat Requirements Rule

Before changing major architecture, navigation, CORI behavior, billing, subscriptions, notifications, build process, or documentation process, check:

`Project Documentation/01_PREVIOUS_CHAT_REQUIREMENTS_REGISTER.md`

Important user requirements from previous Dispatch Spot chats must be captured in active documentation. If a rediscovered requirement is missing from the current docs, update the appropriate active document instead of relying on memory or scattered old chat context.

## 36. Expanded Rule Check Requirement

As of v392, the build response Rule Check should include documentation source-of-truth status:

```text
- Documentation source-of-truth updated if needed: Yes/No
```

If documentation was not relevant to a package, answer `Yes` only when no documentation update was needed and the current source-of-truth remained valid.

## 37. Root Documentation Inventory Rule

As of v393, the root documentation inventory has been classified in:

`Project Documentation/04_ROOT_DOCUMENTATION_INVENTORY_MANIFEST_V393.md`

During documentation cleanup, do not guess whether a root file is active, historical, superseded, duplicate, or an HTML mirror. Use the v393 manifest first.

Current inventory rules:

- root `README*.txt` files are not current build protocol;
- root `.html` files are mirrors when a Markdown source exists;
- v-numbered and foundation files are build history unless promoted into the active consolidated manual;
- old notification, CORI Mail, navigation, and README guidance must be checked against the superseded register;
- v395 completed the controlled root documentation relocation. Use this inventory as the historical classification record for where old root files were moved.

Future documentation cleanup packages should refine references and reduce duplicate wording inside `Project Documentation/`, not recreate root documentation clutter.



## 38. Consolidated Active Product and Architecture Manual Rule

As of v394, the current active product and architecture summary lives in:

`Project Documentation/06_CONSOLIDATED_ACTIVE_PRODUCT_ARCHITECTURE_MANUAL_V394.md`

Before opening older root architecture files for day-to-day decisions, review the consolidated manual first.

Rules:

- older root architecture files remain preserved, but they are not equal to the consolidated manual;
- if an older architecture file conflicts with the consolidated manual, current build rules, placement rules, or user corrections, follow the newer controlling source;
- if a missing requirement is found in an old file or previous chat context, add it to the consolidated manual or previous-chat requirements register rather than relying on memory;
- do not move root documentation until the v393 manifest and v394 manual have both been used to classify and preserve it safely.


## 39. Controlled Documentation Relocation Rule

As of v395, root documentation has been moved into `Project Documentation/` subfolders according to the v393 manifest and v394 consolidated manual.

Rules after v395:

- use `Project Documentation/README.md` as the documentation entry point;
- use `Project Documentation/Active/DISPATCH_SPOT_BUILD_RULES.md` as the active build-rules file;
- do not browse the project root for historical Markdown or HTML guidance;
- do not create new root documentation files except minimal pointer files;
- keep build history, superseded guidance, duplicate scaffold notes, and HTML mirrors inside their assigned documentation subfolders;
- when deploying v395 over older packages, run `node scripts/dispatchspot-doc-relocation-cleanup-v395.mjs` after unzip so old root documentation copies are removed from the server.


## 40. Documentation Reference and Compactness Rule

As of v396, active documentation must stay compact enough to be useful during fast build cycles.

Rules:

- `Project Documentation/Active/DEVELOPMENT_PROTOCOL.md` is a compact protocol pointer, not a long historical log.
- Historical protocol content belongs in `Project Documentation/Build History/`.
- Markdown is the controlling source when Markdown and HTML both exist. HTML mirrors are review copies only.
- Do not create a new one-off document if an existing active manual, source-of-truth file, requirements register, superseded register, changelog, handoff, module standard, or architecture manual can safely hold the update.
- Do not delete historical records to reduce clutter. Archive or classify them instead.
- Use `Project Documentation/08_DOCUMENTATION_REFERENCE_SWEEP_AND_COMPACTNESS_PASS_V396.md` when working on documentation compactness, stale references, duplicate active guidance, or HTML/source mismatch.


## 41. Previous-Chat Cross-Check Rule

As of v397, previous-chat requirements must be checked module-by-module when the user asks for a previous-chat review, documentation cleanup, architecture consolidation, or feature work that depends on older Dispatch Spot decisions.

Use these files first:

- `Project Documentation/01_PREVIOUS_CHAT_REQUIREMENTS_REGISTER.md`
- `Project Documentation/06_CONSOLIDATED_ACTIVE_PRODUCT_ARCHITECTURE_MANUAL_V394.md`
- `Project Documentation/09_PREVIOUS_CHAT_REQUIREMENTS_CROSS_CHECK_V397.md` when auditing previous-chat coverage

Rules:

- Do not rely on memory only for durable product decisions.
- If a previous-chat requirement is valid and missing, add it to the previous-chat register, consolidated manual, or relevant active module standard.
- If older documentation conflicts with the current requirement, add the conflict to the superseded guidance register.
- If the requirement affects placement, settings, provider setup, user-facing language, or CORI behavior, correct the documentation before adding new feature surface.


## 42. Documentation Cleanup Closeout and Product Re-entry Rule

As of v398, the v391-v398 documentation cleanup track is complete enough to return to normal product feature work.

Use:

`Project Documentation/10_DOCUMENTATION_CLEANUP_CLOSEOUT_AND_PRODUCT_REENTRY_PLAN_V398.md`

when checking whether another documentation-only cycle is necessary.

Rules after v398:

- Do not continue broad documentation-only cleanup by default.
- Start normal feature builds from the source-of-truth reading order.
- Update documentation when a durable rule, placement decision, architecture decision, integration boundary, or previous-chat requirement changes.
- Do not create a new one-off documentation file if the changelog, handoff, build rules, operating manual, requirements register, consolidated manual, or relevant module standard can hold the update safely.
- If a new contradiction is found, correct documentation before expanding the affected feature.
- The v398 product re-entry track was completed in v399 with CORI Mail send-review and audit visibility hardening. The next recommended track is notification digest/email trigger behavior.

## v399.1 Deployment Chunk-Load Guard

If a browser shows `ChunkLoadError`, a failed `/_next/static/chunks/...` request, or an application error before a page renders, treat it first as a deployment synchronization issue unless the server build failed.

Future WHM commands should include the deployment hardening steps introduced in v399.1:

```bash
npm run dispatchspot:deploy-cleanup
npm run dispatchspot:preflight
npm run build
npm run dispatchspot:postbuild-restart
```

Do not hide unzip output. Do not continue feature work until the current broken route renders again.

## v400 Notification Digest Placement Rule

Notification digest and email-trigger controls belong in Workspace Settings > Notifications, not on `/notifications`.

Allowed in Workspace Settings > Notifications:

- email alert choices;
- daily digest preference;
- simple delivery readiness;
- digest preview;
- approved manual digest send;
- simple sent/failed/needs-setup wording.

Not allowed on `/notifications`:

- notification preference toggles;
- email digest controls;
- phone capture;
- opt-in or opt-out management;
- provider setup;
- provider diagnostics;
- raw delivery logs;
- SMTP, Twilio, API, or credential fields.

Provider credential setup remains in `/company/integrations`. User-facing delivery failures must use simple action wording and must not expose raw SMTP/Twilio/provider responses.

## v401 Notification Digest History Rule

Digest history, last-send status, retry guidance, and simple send outcome summaries belong in Workspace Settings > Notifications.

Allowed there:

- recent digest send history;
- last attempted/sent timing;
- sent, failed, and waiting counts;
- simple retry guidance;
- sanitized failed-send wording.

Still not allowed there:

- SMTP credentials;
- raw provider responses;
- raw delivery logs;
- provider diagnostics.

Still not allowed on /notifications:

- digest controls;
- digest history;
- notification settings;
- delivery setup or provider setup.

## v402 Notification Scheduled Digest Guard Rule

Notification digest scheduling and trigger checks belong in Workspace Settings > Notifications. The operational `/notifications` page must remain alert/action-only.

Automatic digest sends must remain locked unless the deployment explicitly enables them with `DISPATCH_SPOT_NOTIFICATION_AUTO_DIGEST_ENABLED=true`. Even when enabled, automated digest checks must pass readiness, non-empty digest, duplicate-send, recent-send cooldown, and daily team digest repeat guards before sending.

Provider setup, SMTP credentials, delivery diagnostics, raw logs, and test/debug controls remain in Workspace Integrations or Super Admin, not on operational pages.

## Notification Scheduler/Webhook Rule

Notification scheduler/webhook execution is server-side only. It must be protected by a secret and must never expose provider diagnostics, credentials, or scheduler secrets on operational pages.

Manual trigger checks in Workspace Settings > Notifications may check readiness and show plain-language status. They must not automatically send email. Automatic sends must require the explicit automation environment flag and protected scheduler secret.


## v404 Notification Scheduler Run History Rule

Protected scheduler run history and scheduler health belong in Workspace Settings > Notifications or a future admin health surface. They must not be placed on the operational `/notifications` alert list.

Allowed in Workspace Settings > Notifications:

- scheduler health label;
- recent scheduler run count;
- needs-attention run count;
- last run status;
- simple scheduler run history;
- dry-run/live-check state;
- users checked, sent, ready, skipped, and failed counts.

Not allowed for normal users:

- scheduler secret values;
- raw scheduler authorization details;
- SMTP credentials;
- Twilio credentials;
- raw provider responses;
- raw delivery logs;
- debug traces.

Provider setup remains in `/company/integrations`. `/notifications` remains alert/action-only.

## v405 Super Admin Notification Scheduler Platform Health Rule

Super Admin may see platform-wide notification scheduler health on `/admin/notifications` or another Super Admin health surface.

Allowed in Super Admin scheduler/platform health visibility:

- simple automation-enabled / approval-first state;
- protected webhook configured / not configured state;
- recent scheduler run count;
- workspace count;
- users checked;
- sent count;
- ready-for-approval count;
- skipped count;
- failed / needs-attention count;
- recent run timestamps;
- workspace names tied to scheduler run summaries;
- simple action guidance.

Not allowed in Super Admin browser surfaces:

- scheduler secret values;
- raw authorization headers;
- SMTP credentials;
- raw provider responses;
- raw delivery logs;
- decrypted integration payloads;
- provider diagnostic dumps.

Workspace-level notification preferences and digest controls remain in Workspace Settings > Notifications. Provider setup remains in `/company/integrations`. The operational `/notifications` page remains alert/action-only.

## v406 Notification Scheduler Runbook/Cron Guidance Rule

Scheduler runbook and cron setup guidance may appear in Super Admin notification governance because it is an administrative operations surface. It must not appear on the operational /notifications page.

Allowed in Super Admin runbook guidance:

- endpoint path;
- environment variable names;
- dry-run and live cron command templates with placeholders;
- setup steps;
- verification steps;
- rollback steps;
- safe guardrails;
- plain readiness wording.

Not allowed in browser-facing runbook guidance:

- actual scheduler secret values;
- raw authorization headers containing secrets;
- SMTP credentials;
- Twilio credentials;
- decrypted integration payloads;
- raw provider diagnostics;
- raw delivery logs.

The notification track should now be considered ready to pause unless testing reveals a defect. The next planning track should compare remaining workspaces against the Dispatcher Workspace and define the membership subscription/trial registration workflow.

## v407 Workspace Parity and Subscription/Trial Planning Rule

The notification track is complete enough to pause unless testing reveals a defect. The next planning track is controlled by:

```text
Project Documentation/Architecture/WORKSPACE_PARITY_AND_MEMBERSHIP_SUBSCRIPTION_TRIAL_PLAN.md
```

Rules:

- the Dispatcher Workspace is the maturity benchmark for future role workspaces;
- Broker, Company/Fleet, Driver, Carrier/Owner-Operator, and Shipper/Customer surfaces should match dispatcher-level quality while staying role-specific;
- do not copy dispatcher-only workflows into roles that do not need them;
- every workspace must have a subscription or trial subscription state from creation;
- registration/subscription work must decide workspace type, plan selection timing, trial behavior, entitlements, add-ons, billing status, Stripe handoff, expired-trial handling, and Super Admin visibility before broad role-workspace UI expansion;
- provider setup remains in Workspace Integrations and settings remain in Workspace Settings;
- role workspaces must preserve cross-workspace privacy and avoid exposing internal dispatcher notes to brokers, shippers, drivers, carriers, or customers.

## v408 Super Admin Control Center Planning Rule

Before major Super Admin UI expansion, use the active Super Admin control center plan:

```text
Project Documentation/Architecture/SUPER_ADMIN_CONTROL_CENTER_INFORMATION_ARCHITECTURE_PLAN.md
```

Rules:

- Super Admin must be treated as the platform operations console for Dispatch Spot, not as scattered unrelated admin pages.
- Super Admin pages must follow the same simplification discipline as workspace pages: overview pages summarize and link, list pages manage records, detail pages hold record-specific context, and settings stay in settings/control areas.
- Super Admin controls platform/provider setup, subscription and billing rules, plan limits, feature access, integration availability, platform health, support intervention, security, and audit.
- Workspace Admin controls workspace-level business behavior, assigned resources, operational preferences, and allowed provider usage.
- Operational workspace pages must stay focused on doing the work, not configuring the platform.
- Twilio should be treated as a platform-managed service unless a later architecture decision explicitly changes it: Twilio bills Dispatch Spot, and Dispatch Spot bills workspaces through Stripe according to plan limits, add-ons, assigned phone numbers, and usage rules.
- Drivers do not need independent Dispatch Spot subscriptions by default. Driver users/interfaces are owned by the workspace they drive for.
- Driver surfaces should be mobile-first, road-focused, and limited to the driver's authorized work, earnings visibility, route support, paperwork, communication, alerts, and limited Ask CORI support.


## v409 Role Workspace Planning Rule

Before building deeper Super Admin controls, subscription/trial architecture, workspace-type behavior, Driver Workspace, Freight Broker Workspace, Shipper/Customer portals, internal load board, or internal Dispatch Spot Operations surfaces, review:

`Project Documentation/Architecture/ROLE_WORKSPACE_ARCHITECTURE_AND_SUPER_ADMIN_ADMINISTRATION_REQUIREMENTS.md`

Super Admin should be designed from the actual administration needs of the role workspaces. Do not create isolated Super Admin pages that are not tied to workspace type, subscription, entitlement, integration, usage, support, or audit requirements.

Drivers are owned user/interface roles under a paid workspace by default. They do not need independent subscriptions unless a later architecture decision explicitly creates a separate driver product.

Freight Broker load distribution, carrier email lists, SendGrid-like email distribution, external load-board posting, and internal load-board posting must include plan limits, opt-out/suppression handling, send/post audit, and Super Admin abuse/usage monitoring before live automation is expanded.

## v410 Membership Subscription/Trial and Workspace-Type Architecture Rule

Before changing sign-up UI, Prisma schema, workspace type behavior, subscription enforcement, invited driver/customer/carrier portals, broker load distribution, internal load-board access, or Stripe handoff, review:

`Project Documentation/Architecture/MEMBERSHIP_SUBSCRIPTION_TRIAL_WORKSPACE_TYPE_ARCHITECTURE.md`

Rules:

- every paid customer workspace should have a subscription record from creation, including trial workspaces;
- workspace type and plan selection should happen during registration before workspace creation;
- the initial standard trial policy is 14 days unless Super Admin later changes the policy;
- drivers are owned user/interface roles under a paid workspace by default and do not need independent subscriptions;
- small shipper/customer portals and carrier-response portals are usually owned/invited interfaces, not separate paid workspaces;
- independent Dispatcher, Company/Fleet, Carrier/Owner-Operator, Freight Broker, and large Shipper workspaces are paid workspace types;
- plan visibility must be workspace-type aware so broker plans, fleet plans, dispatcher plans, owner-operator plans, and internal plans are not mixed incorrectly;
- high-cost features such as Twilio phone numbers, SMS, broker load blasts, external load-board posting, internal load-board posting, and heavy CORI/AI usage must be gated by plan, trial posture, billing status, provider readiness, and audit;
- Stripe bills Dispatch Spot SaaS subscriptions, while workspace-level business billing and broker/carrier factoring or Net 30 flows remain separate;
- Prisma schema should not be changed for this area until workspace type, plan visibility, trial policy, owned interfaces, portal access, usage counters, and Super Admin audit requirements are represented in the active architecture.


## v413 schema foundation rule

Workspace type/account class fields and plan family/visibility fields now exist in Prisma, but they are not yet final enforcement gates. Future builds must not block registration, subscription access, driver access, broker distribution, or load-board access solely from inferred or unset classification data. Super Admin classification workflow and audit-backed overrides must be designed before hard gating is enabled.